﻿<navigation:Page x:Class="Silverlight.HierarchicalModel.Home" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows"
    xmlns:dataControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:dataFormControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls"
    xmlns:commonControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:slt="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    d:DesignWidth="800" d:DesignHeight="600"
    MinWidth="800" MinHeight="600"
    Title="Objects">
    <navigation:Page.Resources>
        <DataTemplate x:Key="ListBoxItemTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" />
                <TextBlock Text="{Binding Description}" />
            </StackPanel>
        </DataTemplate>
        <common:HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Objects}">
            <StackPanel>
                <TextBlock Text="{Binding Name}" />
            </StackPanel>
        </common:HierarchicalDataTemplate>
        <DataTemplate x:Key="DataTemplate1">
           <dataControls:DataGrid ItemsSource="{Binding}"/>
        </DataTemplate>
    </navigation:Page.Resources>
    <Grid x:Name="LayoutRoot" Background="#FF666666">
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <commonControls:TreeView Grid.Column="0" Grid.Row="0" BorderThickness="1" BorderBrush="LightGray" Foreground="#FF3D3D3D" Margin="5" x:Name="treeView1"
                ItemTemplate="{StaticResource TreeViewItemTemplate}"
                ItemContainerStyle="{StaticResource ConnectingLinesTreeViewItem}">
            </commonControls:TreeView>
            <Grid Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <dataControls:DataGrid Grid.Column="0" Grid.Row="0" Margin="5" AutoGenerateColumns="True" x:Name="dataGrid1" SelectionChanged="dataGrid1_SelectionChanged"
                    ItemsSource="{Binding SelectedItem.Objects, ElementName=treeView1}">
                </dataControls:DataGrid>
                <dataFormControls:DataForm Grid.Column="1" Grid.Row="0" Margin="5" x:Name="dataForm1" CommandButtonsVisibility="All" AutoCommit="False" AutoEdit="False"
                    ItemsSource="{Binding SelectedItem.Objects, ElementName=treeView1}">
                </dataFormControls:DataForm>
                <dataControls:DataGrid Grid.Column="0" Grid.Row="1" Margin="5" x:Name="dataGrid2" SelectionChanged="dataGrid2_SelectionChanged"
                    ItemsSource="{Binding SelectedItem.Properties, ElementName=treeView1}">
                </dataControls:DataGrid>
                <dataFormControls:DataForm Grid.Column="1" Grid.Row="1" Margin="5" x:Name="dataForm2" CommandButtonsVisibility="All" AutoCommit="False" AutoEdit="False"
                    ItemsSource="{Binding SelectedItem.Properties, ElementName=treeView1}">
                </dataFormControls:DataForm>
            </Grid>
        </Grid>
    </Grid>
</navigation:Page>